1. Technical Field
The present invention relates to an improved data processing system and, in particular, to a method and system for optimizing performance of an object-oriented environment in a data processing system. Still more particularly, the present invention provides a method and system in an object-oriented environment for allocating a persistence indicator for an object, where the persistence indicator indicates a point during the execution of the object-oriented environment at which the allocation of memory for the object occurred.
2. Description of Related Art
Effective management and enhancement of data processing systems requires knowing how and when various system resources are being used. An object-oriented environment supported by the Java(trademark) Programming Language available from Sun Microsystems includes a Java virtual machine (JVM). The JVM may allocate memory from a Java heap where the memory heap allocations and deallocations are hidden from the Java programmer. The allocations are performed by the JVM when new objects are specified. The deallocations are done by the JVM asynchronously at garbage collection (GC) time when there are no longer any references to the object. Because these allocations and deallocations are done by the JVM, the Java programmer is usually not aware of the cost associated with the objects created and may not take care to eliminate references to objects that are not required.
In a performance analysis effort with programs written in Java, the utilization of memory can drastically affect performance. The Java language requires the Java Virtual Machine (JVM) to be responsible for the memory management of the memory area called the heap. The heap is a shared memory area from which memory is allocated for objects. The normal method for allowing reuse of memory locations on the heap for objects which are no longer needed is to perform a garbage collection (GC). During the garbage collection, objects are identified which are no longer in use, and the memory locations where these objects were stored is reclaimed. Objects are in use if they are referenced, either directly or indirectly, by other objects. During the garbage collection, objects can be moved or deallocated from the heap. The time required to perform a garbage collection can significantly affect the total sustained performance and response time of the environment. Thus, it is important to understand information related to both short-lived objects and for persistent objects, that is, those objects that persist between garbage collections.
Therefore, it would be advantageous to provide a method and system for allocating a persistence indicator with an object in an object-oriented environment where the persistence indicator indicates a point during the execution of the object-oriented environment at which the allocation of memory for the object occurred.
A method and system are disclosed for operating an object-oriented environment within a computer system. The execution of the object-oriented environment is initiated. A first memory location is allocated in a memory area within the object-oriented environment for storing an object. A second memory location is allocated in the memory area concurrently with the allocation of the first memory location for storing a persistence indicator. The persistence indicator indicates a point during the execution of the object-oriented environment at which the allocation of the first memory location occurred. A total number of bytes of the memory area which had been allocated during the execution of the object-oriented environment when the allocation of the first memory location occurred is stored as the persistence indicator.
The above as well as additional objectives, features, and advantages of the present invention will become apparent in the following detailed written description.